import { HashMap } from "../../api/struct/HashMap";
import { CDWelfareSign } from "../excel/CDWelfareSign";


/**
 * 扩展-福利签到
 */
export abstract class CEWelfareSignIn {
    /**列表 */
    private static readonly weekMap = new HashMap<number, HashMap<number, CDWelfareSign>>();


    /**
     * 初始化
     */
    public static init(): void {
        const map = this.weekMap;
        if (map.size() > 0) {
            return;
        }
        const vs = CDWelfareSign.datas.getValues();
        for (let i = 0, len = vs.length; i < len; i++) {
            const config = vs[i];
            let dayMap = map.get(config.week);
            if (!dayMap) {
                dayMap = new HashMap<number, CDWelfareSign>();
                map.put(config.week, dayMap);
            }
            dayMap.put(config.day - 1, config);     //-1是因为配置数据第一天为1，程序默认从0开始
        }
    }


    /**
     * 获取福利配置
     * @param week 
     * @param day 
     */
    public static getConfig(week: number, day: number): CDWelfareSign {
        const dayMap = this.weekMap.get(week) || this.weekMap.get(-1);
        if (dayMap){
            return dayMap.get(day);
        }
        return null;
    }
}